package com.lb.ai.common.response.code;

import com.lb.ai.common.response.IResultCode;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 业务模块响应码
 *
 * @author LiuB
 */
public class BusinessModule extends ResultCodeModule {
    
    public BusinessModule() {
        super(3, "业务模块");
    }
    
    @Getter
    @AllArgsConstructor
    public enum Code implements IResultCode {
        
        // 参数相关 1xx
        PARAM_MISSING(101, "参数缺失"),
        PARAM_ERROR(102, "参数错误"),
        PARAM_PARSE_ERROR(103, "参数解析错误"),
        
        // 数据相关 2xx
        DATA_NOT_EXIST(201, "数据不存在"),
        DATA_ALREADY_EXIST(202, "数据已存在"),
        DATA_STATUS_ERROR(203, "数据状态错误"),
        
        // 文件相关 3xx
        FILE_NOT_FOUND(301, "文件不存在"),
        FILE_UPLOAD_FAILED(302, "文件上传失败"),
        FILE_DOWNLOAD_FAILED(303, "文件下载失败"),
        FILE_TYPE_ERROR(304, "文件类型错误"),
        FILE_SIZE_EXCEED(305, "文件大小超限"),
        
        // 订单相关 4xx
        ORDER_NOT_EXIST(401, "订单不存在"),
        ORDER_ALREADY_PAID(402, "订单已支付"),
        ORDER_ALREADY_CANCELLED(403, "订单已取消"),
        ORDER_STATUS_ERROR(404, "订单状态错误"),
        
        // 支付相关 5xx
        PAY_FAILED(501, "支付失败"),
        PAY_TIMEOUT(502, "支付超时"),
        PAY_AMOUNT_ERROR(503, "支付金额错误"),
        REFUND_FAILED(504, "退款失败");
        
        private final Integer code;
        private final String message;
        
        @Override
        public Integer getCode() {
            return new BusinessModule().generateCode(code);
        }
    }
    
    @Override
    public IResultCode[] getCodes() {
        return Code.values();
    }
} 